
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class JDBC {

    public static void main(String[] args) throws Exception {
        PreparedStatement ps = null;
        try {
            Properties p = new Properties();
            p.load(new FileInputStream("jdbc.porperties"));

            //new com.mysql.cj.jdbc.Driver()
            Class.forName("com.mysql.cj.jdbc.Driver");// 反射机制注册驱动 运行时加载类
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/assignment", "java", "java12345");

            ps = con.prepareStatement("insert into tbStudent(id,name,gender)valuse(?,?,?)");

            ps.setString(1, "007");
            ps.setString(2, "张三");
            ps.executeUpdate();

            // OR Mapping 对象关系映射工具
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("select * from tbStudent");
            while (rs.next()) {
                System.out.println("id = " + rs.getString("id") + ", name = " + rs.getString("d"));
            }
            rs.close();
            stmt.close();
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class A {

    static {

    }
}

public class Student {

    private String id, name;

    private Map<String, Object> data = new HashMap<String, Object>();

    public void set(String pname, Object value) {
    }

    public Object get(String name, Object value) {
        Object o;
        return o;
    }

}
